package com.kehutong.common;

import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;

import org.coraframework.util.Queue;

public class SortedQueue<E> extends Queue<E> {
	
	public SortedQueue() {
		this.queue = new PriorityQueue<E>();
		this.map = new HashMap<>();
	}
	
	private PriorityQueue<E> queue;
	private Map<String, E> map;
	
	@Override
	public void push(E item) {
		queue.offer(item);
	}

	@Override
	public E pop() {
		return queue.poll();
	}
	
	@Override
	public E peek() {
		return queue.peek();
	}
	
	@Override
	public int size() {
		return queue.size();
	}
	
	public void putItem(String key, E item) {
		map.put(key, item);
	}
	
	public E getItem(String key) {
		return map.get(key);
	}
	
	public void removeItem(String key) {
		map.remove(key);
	}
}
